package com.hfxt.j96springboot.web;

import com.hfxt.j96springboot.entity.TbUser;
import com.hfxt.j96springboot.service.TbUserService;
import com.hfxt.j96springboot.web.redis.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("index")
public class IndexController {



  //  @Autowired
   // protected RedisTemplate redisTemplate;

    @Autowired
    protected RedisUtil redisUtil;

    @Autowired
    protected TbUserService tbUserService;

    @RequestMapping("/index.html")
    @ResponseBody
    public  String index(){
        TbUser tbUser=(TbUser)redisUtil.get("user");
        if(tbUser==null){
            tbUser=tbUserService.getUserByUsername("zhangsan");
            redisUtil.set("user",tbUser);
        }
        return "index";
    }
}
